@use 'sass:map';

.xdsoft_datetimepicker {
  box-shadow: 0 5px 10px -5px theme('colors.black-35');
  background: $color-white;
  border: 1px solid $color-input-border;
  padding: 8px;
  padding-inline-start: 0;
  padding-top: 2px;
  position: absolute;
  z-index: 5;
  box-sizing: border-box;
  display: none;

  * {
    box-sizing: border-box;
    padding: 0;
    margin: 0;
  }

  iframe {
    position: absolute;
    inset-inline-start: 0;
    top: 0;
    width: 75px;
    height: 210px;
    background: transparent;
    border: 0;
  }

  .xdsoft_datepicker,
  .xdsoft_timepicker {
    display: none;

    &.active {
      display: block;
    }
  }

  .xdsoft_datepicker {
    float: left;
    margin-inline-start: 8px;
  }

  .xdsoft_datepicker.active + .xdsoft_timepicker {
    margin-top: 8px;
    margin-bottom: 3px;
  }

  .xdsoft_mounthpicker {
    position: relative;
    text-align: center;
  }

  .xdsoft_next,
  .xdsoft_prev,
  .xdsoft_today_button {
    background-color: transparent;
    cursor: pointer;
    display: block;
    border: 0;
    overflow: hidden;
    padding: 5px 0;
    position: relative;
    white-space: nowrap;
    width: 2em;
    color: $color-teal;
    text-align: center;

    &:before {
      font-size: 1.5em;
      font-family: $font-wagtail-icons;
      width: 1em;
      line-height: 1.3em;
      text-align: center;
      margin: 0;
    }

    &:hover {
      color: $color-teal-darker;
    }
  }

  .xdsoft_prev {
    float: left;

    &:before {
      content: map.get($icons, 'arrow-left'); // UI-Redesign: to be removed
    }
  }

  .xdsoft_today_button {
    float: left;
    margin-inline-start: 5px;

    &:before {
      content: map.get($icons, 'home'); // UI-Redesign: to be removed
    }
  }

  .xdsoft_next {
    float: right;

    &:before {
      content: map.get($icons, 'arrow-right'); // UI-Redesign: to be removed
    }
  }

  .xdsoft_timepicker {
    min-width: 70px;
    float: left;
    text-align: center;
    margin-inline-start: 8px;
    margin-top: 0;

    .xdsoft_prev,
    .xdsoft_next {
      float: none;
      height: 1.5em;
      display: block;
      text-align: center;
      width: 100%;
      padding: 0;

      &:before {
        width: 100%;
      }
    }

    .xdsoft_prev:before {
      content: map.get($icons, 'arrow-up'); // UI-Redesign: to be removed
    }

    .xdsoft_next:before {
      content: map.get($icons, 'arrow-down'); // UI-Redesign: to be removed
    }

    .xdsoft_time_box {
      position: relative;
      border: 1px solid $color-grey-4;
      height: 170px;
      overflow: hidden;

      > div > div {
        background: $color-grey-5;
        border-top: 1px solid $color-grey-4;
        color: $color-grey-1;
        font-size: 1em;
        text-align: center;
        border-collapse: collapse;
        cursor: pointer;
        border-bottom-width: 0;
        height: 2.3em;
        line-height: 2.3em;
        padding-inline-start: 0.6em;
        padding-inline-end: 0.6em;

        // stylelint-disable-next-line max-nesting-depth
        &:first-child {
          border-top-width: 0;
        }
      }
    }
  }

  .xdsoft_label {
    display: inline;
    position: relative;
    z-index: 9999;
    margin: 0;
    padding: 5px 3px;
    font-size: 14px;
    line-height: 20px;
    font-weight: bold;
    background-color: $color-white;
    float: left;
    width: 182px;
    text-align: center;
    cursor: pointer;

    &:hover {
      text-decoration: underline;
    }

    > .xdsoft_select {
      border: 1px solid $color-grey-4;
      position: absolute;
      inset-inline-end: 0;
      top: 30px;
      z-index: 101;
      display: none;
      background: $color-white;
      max-height: 160px;
      overflow-y: hidden;

      &.xdsoft_monthselect {
        inset-inline-end: -7px;
      }

      &.xdsoft_yearselect {
        inset-inline-end: 2px;
      }

      > div > .xdsoft_option:hover {
        background: theme('colors.secondary.75');

        // stylelint-disable-next-line max-nesting-depth
        @media (forced-colors: active) {
          background: SelectedItem;
        }
      }

      > div > .xdsoft_option {
        padding: 2px 15px 2px 5px;
      }
    }
  }

  .xdsoft_month {
    width: 90px;
    text-align: end;
  }

  .xdsoft_year {
    width: 56px;
  }

  .xdsoft_calendar {
    clear: both;

    table {
      border-collapse: collapse;
    }

    td > div {
      padding-inline-end: 5px;
    }

    td,
    th {
      width: 14.285%;
      border: 1px solid $color-grey-4;
      color: $color-grey-1;
      font-size: 12px;
      text-align: end;
      padding: 5px 7px;
      border-collapse: collapse;
      cursor: pointer;
      height: 25px;
    }

    td {
      background-color: $color-white;
    }

    th {
      background: $color-grey-5;
      font-weight: 700;
      font-size: 0.85em;
      text-align: center;
      cursor: default;
    }
  }

  .xdsoft_calendar td.xdsoft_default,
  .xdsoft_calendar td.xdsoft_current,
  .xdsoft_timepicker .xdsoft_time_box > div > div.xdsoft_current {
    background: theme('colors.secondary.75');
    font-weight: 700;

    @media (forced-colors: active) {
      background: SelectedItem;
    }
  }

  .xdsoft_calendar td.xdsoft_other_month,
  .xdsoft_calendar td.xdsoft_disabled,
  .xdsoft_time_box > div > div.xdsoft_disabled {
    opacity: 0.5;
    background: $color-grey-3;

    @media (forced-colors: active) {
      opacity: 1;
      color: GrayText;
    }
  }

  .xdsoft_calendar td.xdsoft_other_month.xdsoft_disabled {
    opacity: 0.2;

    @media (forced-colors: active) {
      opacity: 1;
      color: GrayText;
    }
  }

  .xdsoft_calendar td:hover,
  .xdsoft_timepicker .xdsoft_time_box > div > div:hover {
    color: $color-white;
    background: $color-teal;
  }

  .xdsoft_calendar td.xdsoft_today {
    font-weight: 700;
  }
}

.xdsoft_noselect {
  user-select: none;
}

.xdsoft_noselect::selection {
  background: transparent;
}

.xdsoft_noselect::-moz-selection {
  background: transparent;
}

.xdsoft_datetimepicker.xdsoft_inline {
  display: inline-block;
  position: static;
  box-shadow: none;
}

.xdsoft_scroller_box {
  position: relative;
}

.xdsoft_scrollbar {
  position: absolute;
  width: 7px;
  inset-inline-end: 0;
  top: 0;
  bottom: 0;
  cursor: pointer;

  > .xdsoft_scroller {
    // stylelint-disable-next-line declaration-no-important
    background: $color-grey-3 !important;
    height: 20px;
    border-radius: 3px;
  }
}
